#include <bits/stdc++.h>
using namespace std;

void fileIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    map<string, string> mp;
    for(int i = 1; i <= n; i ++) {
        string name, id;
        cin >> id;
        while(id[0] < '0' || id[0] > '9') {
            name += id;
            name += " ";
            cin >> id;
        }
        name.pop_back();
        mp[name] = id;
        mp[id] = name;
    }

    int m;
    cin >> m; 
    {
        string t;
        getline(cin, t);
    }
    for(int i = 1; i <= m; i ++) {
        string t;
        getline(cin, t);
        if(mp.count(t)) cout << mp[t] << "\n";
        else cout << "Not Found!\n";
    }

    return 0;
}